package com.wzapp.sitposture.eshop.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wzapp.sitposture.common.converter.BigDecimalConverterJson;
import com.wzapp.sitposture.common.converter.DateConverterJson;
import com.wzapp.sitposture.common.converter.DefaultDateConverterJson;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;

@Data
@Entity(name = "user_order")
public class Order implements Serializable{
    @JsonIgnore
    private static final long serialVersionUID = 7204897058769016341L;

    @Id
    @GeneratedValue(generator = "uuid_32")
    @GenericGenerator(name = "uuid_32", strategy = "uuid")
    @Column(length = 32)
    private String id;

    /**
     * 订单号
     */
    @Column(length = 60)
    private String orderCode;
    /**
     * 买家ID
     */
    private String userId;
    /**
     * 公共状态，参看状态机
     */
    private Integer status;
    /**
     * 总价，单位：元
     */
    @Convert(converter = BigDecimalConverterJson.class)
    private Double amount;
    /**
     * 支付总额，单位：元，支付时写入
     */
    @Convert(converter = BigDecimalConverterJson.class)
    private Double payAmount;
    /**
     * 支付方式: 1-支付宝，2-微信，支付时写入
     */
    private Integer payMethod;
    /**
     * 第三方支付交易号，支付时写入
     */
    @Column(length = 60)
    private String payCode;
    /**
     * 支付时间，毫秒，支付时写入
     */
    @Convert(converter = DefaultDateConverterJson.class)
    private Long payTime;
    /**
     * 创建时间，毫秒
     */
    @Column(updatable = false)
    @Convert(converter = DateConverterJson.class)
    private Long createTime;
    /**
     * 更新时间，毫秒
     */
    @Convert(converter = DateConverterJson.class)
    private Long updateTime;
    /**
     * 跳转路由
     */
    private String router;

    /**
     * 邀请人id
     */
    private String recommendUserId;
}
